/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 * @flow
 * @lint-ignore-every XPLATJSCOPYRIGHT1
 */

import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View,Alert,TouchableOpacity,Image} from 'react-native';
import {createAppContainer,createStackNavigator,createDrawerNavigator} from 'react-navigation';
//import {Drawer} from './src/Drawer';
import TabNav from './src/TabNav';
//import MainPage from './src';
//import {sideBar} from './src/sideBar';
import RegisterPage from './src/page/login/register';
import LoginPage from './src/page/login';
import CatePage from './src/page/cate';
import NewsPage from './src/page/news';
import SettingPage from './src/page/setting';

const isLogin=false;

/**/
/*const instructions = Platform.select({
  ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
  android:
    'Double tap R on your keyboard to reload,\n' +
    'Shake or press menu button for dev menu',
});

const App = createStackNavigator({
  Register:RegisterPage,
  Login:LoginPage,
  Cate:CatePage,
  News:NewsPage,
  sideBar:{
    screen:sideBarPage,
    navigationOptions:({navigation})=>{
      console.log(navigation)
      return{
        title:'asdfasdfasdfasd',
        //headerLeft:<TouchableOpacity onPress={()=>navigation.openDrawer()}><View style={{flex:1,justifyContent:'center',alignItems: 'center',}}><Text>hel</Text></View></TouchableOpacity>
      }
    }
  },
  Main:TabNav
},{
  navigationOptions:{
    gesturesEnabled:false//滑动返回手势
  },
  initialRouteName:'Main',
  mode: 'modal',
  defaultNavigationOptions:{
    headerTitleStyle:{flex: 1,textAlign:'center'}
  },
  //headerMode: 'none',去除头部标题
})*/
const CateStack=createStackNavigator({
  Cate:{
    screen:CatePage,
    navigationOptions:{
      title : '分类',
      headerTitleStyle:{
          flex:1,
          textAlign: 'center',
      }
    }
  }
})
const SettingStack=createStackNavigator({
  Setting:{
    screen:SettingPage,
    navigationOptions:{
      title : '设置',
      headerTitleStyle:{
          flex:1,
          textAlign: 'center',
      }
    }
  }
})
const Drawer = createDrawerNavigator({
    Home:{
      screen:TabNav,
      navigationOptions:{
        drawerLabel: '首页',
        drawerIcon: ({ tintColor }) => (
        <Image
            source={require('./src/img/i1.png')}
            style={[styles.icon, {tintColor: tintColor}]}
        />
        )
      },
  },
  Cate:{
      screen:CateStack,
      navigationOptions:{
        drawerLabel: '分类',//(<Text>分类</Text>),
        drawerIcon: ({ tintColor }) => (
        <Image
            source={require('./src/img/i2.png')}
            style={[styles.icon, {tintColor: tintColor}]}
        />
        )
      },/**/
  },
  News:{
      screen:NewsPage,
      navigationOptions:{
        drawerLabel: '新闻',
        drawerIcon: ({ tintColor }) => (
        <Image
            source={require('./src/img/i1.png')}
            style={[styles.icon, {tintColor: tintColor}]}
        />
        )
      },
  },
  Setting:{
      screen:SettingStack,
      navigationOptions:{
        drawerLabel: '设置',
        drawerIcon: ({ tintColor }) => (
        <Image
            source={require('./src/img/i1.png')}
            style={[styles.icon, {tintColor: tintColor}]}
        />
        )
      },
  }
});
const AppStack=createStackNavigator({
  Register:RegisterPage,
  Login:LoginPage,
  Main:Drawer
},{
  defaultNavigationOptions:{
    header:null
  },
  initialRouteName:'Main'
})
export default createAppContainer(AppStack);
/*export default class App extends Component{
  textTap(){
    console.log('aaa')
    Alert.alert('hello')
  }
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome} onPress={this.textTap}>Welcome to React Native!</Text>
        <Text style={styles.instructions}>To get started, edit App.js</Text>
        <Text style={styles.instructions}>{instructions}</Text>
      </View>
    );
  }
}
*/
const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
  icon: {
    width: 24,
    height: 24,
  },
  
});
